package com.hnair.grpc.example.service;

import com.github.examples.grpc.lib.HelloReply;
import com.github.examples.grpc.lib.HelloRequest;
import com.github.examples.grpc.lib.SimpleGrpc;
import com.github.grpc.server.annotation.GrpcService;
import io.grpc.stub.StreamObserver;

@GrpcService(SimpleGrpc.class)
public class HelloService extends SimpleGrpc.SimpleImplBase {

    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("hello:"+request.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}
